package com.duobaoyu.dby.supply.biz.client.boundary.message.handler;

import com.duobaoyu.dby.channel.adapter.constant.ChannelConstant;
import com.duobaoyu.dby.supply.biz.client.boundary.message.AbstractSupplyMessageHandlerStrategy;
import com.duobaoyu.dby.supply.biz.client.boundary.message.bean.pojo.MessagePayload;
import com.duobaoyu.dby.supply.db.constant.SupplyMapperConstant;
import com.duobaoyu.dby.supply.db.entity.message.ChannelMessageProduct;
import com.duobaoyu.dby.supply.db.helper.DynamicTableNameHelper;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.Set;

/**
 * @author liyang
 * @version 1.0.0
 * @ClassName SupplyProductMessageHandlerStrategy
 * @Description 商品消息处理器
 * @createTime 16:01:00 2023/09/27
 */
@Component
@RequiredArgsConstructor
public class SupplyProductMessageHandlerStrategy extends AbstractSupplyMessageHandlerStrategy {
	@Override
	protected Set<String> messageLabels() {
		return Sets.newHashSet(ChannelConstant.PRODUCT_MESSAGE_LABEL);
	}

	@Override
	protected Object beforeHandler(MessagePayload messagePayload) {
		Map<String, Object> map = Maps.newHashMap();
		map.put(SupplyMapperConstant.CHANNEL_MESSAGE_TABLE_NAME, SupplyMapperConstant.CHANNEL_MESSAGE_PRODUCT_SUFFIX);
		DynamicTableNameHelper.setRequestData(map);
		return ChannelMessageProduct.class;
	}

}
